<?
//exployer
$sql    = "SELECT * FROM `pa_employer` ORDER BY ep_id DESC LIMIT 0,5";
$result = $DB->query($sql);

$i=0;
while($list = $DB->fetch_array($result)){
   $data_employer[$i] = $list;
   $data_employer[$i][ep_industry] =$jobcategory[$list[ep_industry]];
   $data_employer[$i][loc] = $list[ep_city].", ".$state[$list[ep_state]];
   $i++;
}
$smarty->assign("employerdb",$data_employer);

//candidate

$sql    = "SELECT * FROM `pa_candidates` ORDER BY js_id DESC LIMIT 0,5";
$result = $DB->query($sql);

$i=0;
while($list = $DB->fetch_array($result)){
   $data_candidate[] = $list;
    $data_candidate[$i][loc] = $list[js_city].", ".$state[$list[js_state]];
	$i++;
}
$smarty->assign("candidatedb",$data_candidate);

//recruiter

$sql    = "SELECT * FROM `pa_recuiter` ORDER BY rc_id DESC LIMIT 0,5";
$result = $DB->query($sql);
$i=0;
while($list = $DB->fetch_array($result)){
   $data_recruiter[$i] = $list;
   $data_recruiter[$i][rc_industry] = $jobcategory[$list[rc_industry]];
   $data_recruiter[$i][loc] = $list[rc_city].", ".$state[$list[rc_state]];
   $i++;
}
$smarty->assign("recruiterdb",$data_recruiter);

//advisor
$sql    = "SELECT * FROM `pa_advisory` ORDER BY ad_id DESC LIMIT 0,5";
$result = $DB->query($sql);
$i=0;

while($list = $DB->fetch_array($result)){
   $data_advisor[$i] = $list;
   $data_advisor[$i][ad_industry] = $jobcategory[$list[ad_industry]];
   $data_advisor[$i][loc] = $list[ad_city].", ".$state[$list[ad_state]];
   $i++;
}
$smarty->assign("advisordb",$data_advisor);

//jobs
$job_contact_type = "";
$and_sql = "";
switch($_SESSION["usertype"]){
	case 'employer':
		$job_contact_type = 3;
		$and_sql = " WHERE FIND_IN_SET('2', jo_contact) OR FIND_IN_SET('3', jo_contact)";
		break;
	case 'recruiter':
		$job_contact_type = 2;
		$and_sql = " WHERE FIND_IN_SET('2', jo_contact) OR FIND_IN_SET('3', jo_contact)";
		break;
	case 'candidate':
		$job_contact_type = 1;
		$and_sql = " WHERE FIND_IN_SET('1', jo_contact)";
		break;
	default:
		break;
}

$sql    = "SELECT * FROM `pa_job` ".$and_sql." ORDER BY jo_id DESC LIMIT 0,5";
$result = $DB->query($sql);
$i=0;
while($list = $DB->fetch_array($result)){
   $data_jobs[$i] = $list;
   $data_jobs[$i][jo_category] = $jobcategory[$list[jo_category]];
   $data_jobs[$i][loc] = $list[ad_city].", ".$state[$list[ad_state]];
   $data_jobs[$i][location]    =  $list[jo_city].", ".$state[$list[jo_state]] ;
   $data_jobs[$i][regtime]     =  date("m/d/Y",$list[jo_regtime]);
   $i++;
}
$smarty->assign("jobsdata",$data_jobs);

$logos = $DB->fetch_one_array("SELECT * FROM pa_settings WHERE `key` = 'slide_show'");
$imgurlArr = json_decode($logos['value'],true);
$smarty->assign("imgurlArr",$imgurlArr);
?>